#ifndef GB28181_CATALOG_H
#define GB28181_CATALOG_H

#include <string>
#include <vector>

namespace El {
namespace GB28181 {

// Forward declarations
struct SipServerConfig;

// Catalog and device info handler for GB28181 protocol
class GB28181Catalog {
public:
    // Device information structure
    struct DeviceInfo {
        std::string device_id;
        std::string device_name;
        std::string manufacturer;
        std::string model;
        std::string firmware;
        int max_camera;
        int max_alarm;
    };
    
    // Channel information structure
    struct ChannelInfo {
        std::string device_id;
        std::string name;
        std::string manufacturer;
        std::string model;
        std::string owner;
        std::string civil_code;
        std::string address;
        int parental;
        int safety_way;
        int register_way;
        std::string status;
    };
    
    // Create device info XML response
    static std::string CreateDeviceInfoXml(const SipServerConfig &config, const std::string &sn);
    
    // Create catalog XML response
    static std::string CreateCatalogXml(const SipServerConfig &config, const std::string &sn);
    
    // Create channel list XML
    static std::string CreateChannelListXml(const std::vector<ChannelInfo> &channels);
    
    // Parse device info query XML
    static bool ParseDeviceInfoQuery(const std::string &xml, std::string &sn, std::string &device_id);
    
    // Parse catalog query XML  
    static bool ParseCatalogQuery(const std::string &xml, std::string &sn, std::string &device_id);
    
    // Generate channel ID from base device ID and channel index
    static std::string GenerateChannelId(const std::string &device_id, int channel_index);
    
    // Get default device info
    static DeviceInfo GetDefaultDeviceInfo(const std::string &device_id, int channel_count);
    
    // Get default channel info
    static ChannelInfo GetDefaultChannelInfo(const std::string &device_id, int channel_index, 
                                           const std::string &civil_code);
};

} // namespace GB28181
} // namespace El

#endif // GB28181_CATALOG_H